import request from '@/utils/axios'

export interface ApiAccessLogType {
  id: number
  traceId: string
  userId: number
  userType: number
  applicationName: string
  requestMethod: string
  requestParams: string
  requestResult: string
  requestUrl: string
  userIp: string
  userAgent: string
  operateModule: string
  operateType: number
  beginTime: Date
  endTime: Date
  duration: number
  resultCode: number
  resultMsg: string
  create_time: Date
}

export interface AccessLogPageReqType extends PageParam {
  userId?: number
  userType?: number
  applicationName?: string
  duration?: string
  resultCode?: string
  beginTime?: Date[]
}

/**
 * 访问日志接口
 */
export const AccessLogApi = {
  // 查询分页列表
  page: (params: AccessLogPageReqType) => {
    return request.get({ url: '/infra/api-access-log/page', params, is_mock: true })
  },
  // 导出日志
  export: (params: AccessLogPageReqType) => {
    return request.get({ url: '/infra/api-access-log/export', params, is_mock: true })
  }
}
